/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.anachronos.jeep.model.trace.impl;

import java.util.Collection;

import org.anachronos.jeep.model.trace.Method;
import org.anachronos.jeep.model.trace.TracePackage;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Method</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.anachronos.jeep.model.trace.impl.MethodImpl#getArgumentTypes <em>Argument Types</em>}</li>
 *   <li>{@link org.anachronos.jeep.model.trace.impl.MethodImpl#getReturnType <em>Return Type</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class MethodImpl extends NamedElementImpl implements Method {
	/**
	 * The cached value of the '{@link #getArgumentTypes() <em>Argument Types</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getArgumentTypes()
	 * @generated
	 * @ordered
	 */
	protected EList<org.anachronos.jeep.model.trace.Class> argumentTypes;

	/**
	 * The cached value of the '{@link #getReturnType() <em>Return Type</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getReturnType()
	 * @generated
	 * @ordered
	 */
	protected org.anachronos.jeep.model.trace.Class returnType;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MethodImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return TracePackage.Literals.METHOD;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<org.anachronos.jeep.model.trace.Class> getArgumentTypes() {
		if (argumentTypes == null) {
			argumentTypes = new EObjectEList<org.anachronos.jeep.model.trace.Class>(org.anachronos.jeep.model.trace.Class.class, this, TracePackage.METHOD__ARGUMENT_TYPES);
		}
		return argumentTypes;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public org.anachronos.jeep.model.trace.Class getReturnType() {
		return returnType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setReturnType(org.anachronos.jeep.model.trace.Class newReturnType) {
		org.anachronos.jeep.model.trace.Class oldReturnType = returnType;
		returnType = newReturnType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TracePackage.METHOD__RETURN_TYPE, oldReturnType, returnType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case TracePackage.METHOD__ARGUMENT_TYPES:
				return getArgumentTypes();
			case TracePackage.METHOD__RETURN_TYPE:
				return getReturnType();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case TracePackage.METHOD__ARGUMENT_TYPES:
				getArgumentTypes().clear();
				getArgumentTypes().addAll((Collection<? extends org.anachronos.jeep.model.trace.Class>)newValue);
				return;
			case TracePackage.METHOD__RETURN_TYPE:
				setReturnType((org.anachronos.jeep.model.trace.Class)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case TracePackage.METHOD__ARGUMENT_TYPES:
				getArgumentTypes().clear();
				return;
			case TracePackage.METHOD__RETURN_TYPE:
				setReturnType((org.anachronos.jeep.model.trace.Class)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case TracePackage.METHOD__ARGUMENT_TYPES:
				return argumentTypes != null && !argumentTypes.isEmpty();
			case TracePackage.METHOD__RETURN_TYPE:
				return returnType != null;
		}
		return super.eIsSet(featureID);
	}

} //MethodImpl
